package com.platform.qujia.utils;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;

/**
 * @date 2023/11/22
 */
public class MyLambadaUpdateWrapper<T> extends LambdaUpdateWrapper<T> {

    public MyLambadaUpdateWrapper<T> incrementSet(boolean condition, SFunction<T, ?> column, Object val){
        if (condition) {
            String columnName = this.columnToString(column);
            this.setSql(condition,String.format("%s=%s+%s", columnName, columnName, this.formatSql("{0}", val)));

        }
        return (MyLambadaUpdateWrapper<T>)this.typedThis;
    }

    public MyLambadaUpdateWrapper<T> incrementSet(SFunction<T, ?> column, Object val){
        return incrementSet(true,column,val);
    }

}
